﻿@using Nutrapp.HtmlHelpers;
@model Nutrapp.Models.RecipeListViewModel

@{
    ViewBag.Title = "Index";
}



<div class="row">

    <div>
        <div class="text-right">@Html.ActionLink("Create Recipe", "Create", "Recipe", null, new { @class = "btn btn-primary" })</div>
        @if (Model == null)
        {
            <p>There is no recipes at the moment.</p>
        }
        else
        {
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Image</th>
                        <th>Cost</th>
                        <th>Rate</th>

                        <th>Instruction</th>
                    </tr>

                </thead>
                <tbody>
                    @foreach (var item in Model.recipes)
                    {
                        <tr>
                            <td>@item.Name</td>
                            <td>@item.Picture</td>
                            <td>@item.Cost</td>
                            <td>@item.Rating</td>
                            <td>@item.Instruction</td>
                            <td>@Html.ActionLink("Edit", "Edit", "Recipe", new { id = item.ID }, new { @class = "btn btn-default" })</td>
                            <td>
                                @using (Html.BeginForm("Delete", "Recipe"))
                                {
                                    @Html.Hidden("ID", item.ID)
                                    <input type="submit" class="btn btn-default" value="Delete" />
                                }
                            </td>
                            @*@Html.ActionLink("Delete", "Delete", "Recipe", new { id = item.ID }, null)*@
                        </tr>
                    }
                </tbody>
            </table>
        }
    </div>



</div>

<div>
    @Html.PageLinks(Model.PagingInfo, x => Url.Action("Index", new { page = x }))
</div>
